package com.atguigu.b_generic_class;

import java.util.Objects;

public class Student<P> {
    private String name;
    //String age -> 18 -> 18 + ""
    //int age -> "18" -> Integer.parseInt("18")
    private P age;

    public Student() {
    }

    public Student(String name, P age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public P getAge() {
        return age;
    }

    public void setAge(P age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student<?> student = (Student<?>) o;
        return Objects.equals(name, student.name) && Objects.equals(age, student.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
